import {Entity, PrimaryGeneratedColumn, Column, Timestamp, ManyToOne} from 'typeorm'
import {BookEntity} from '../book/book.entity'


@Entity({name: 'parts'})
export class PartEntity {
    @PrimaryGeneratedColumn({comment: '主键id'})
    id: number;

    @Column({length: 20, comment: '标记'})
    markId: string;

    @Column({comment: '内容', length: 500})
    content: string;

    @Column({comment: '批注数量'})
    annotationCount: number;

    @Column({comment: '书本id'})
    bookId: number;

    @Column({comment: '目录id'})
    chapterId: number;

    @ManyToOne((type) => BookEntity, (book) => book.parts)
    book: BookEntity

    @Column({type: 'timestamp', default: () => 'current_timestamp'})
    bookTime: Timestamp;

    @Column({type: 'timestamp', default: () => 'current_timestamp'})
    createTime: Timestamp;

    @Column({type: 'timestamp', onUpdate: 'current_timestamp', default: () => 'current_timestamp'})
    updateTime: Timestamp;
}